<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopCategoryTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_category', ['comment' => '分类', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '分类名称'])
            ->addColumn('parent_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '所属分类'])
            ->addColumn('style', 'string', ['limit'  =>  30, 'null' => true, 'default' => null, 'comment' => '样式'])
            ->addColumn('image', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '图片'])
            ->addColumn('description', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '描述'])
            ->addColumn(Column::enum('status', ['normal', 'hidden'])->setDefault('normal')->setComment('状态:normal=正常,hidden=隐藏'))
            ->addColumn('weigh', 'integer', ['limit'  =>  8, 'default' => 0, 'comment' => '权重'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_category');
        $table->drop();
    }
}
